<html>
<head>
	<title>{$item['title']}</title>
	
	<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
	<meta name="format-detection" content="telephone=no" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="{$file}/public/font-awesome-4.4.0/css/font-awesome.min.css" rel="stylesheet">	
	<link rel="stylesheet" type="text/css" href="{$file}/public/css/weui.min.css" />		
	<link rel="stylesheet" type="text/css" href="{$file}/public/css/rain.css" />
	<script type="text/javascript" src="{$file}/public/js/jquery.min.js" ></script>
	<script type="text/javascript" src="{$file}/public/js/zepto.min.js" ></script>	
</head>
<body>
<style>
.fe-floatback {width: 32px; position: fixed; top: 4px;left:4px; text-align: center; z-index: 1003;}
.fe-floatback a{ display: block; width: 32px; height: 32px;}
.fe-floatback a img{width:32px;height:32px;opacity:0.5;}
</style>
<div class="fe-floatback">
		<a href="{$backurl}">
			<img src="../core/resource/images/goback.png"></i>
		</a>
</div>
{if 0 == 0}
	<!-- 拆红包 -->
	{if time() > $item['starttime'] && $item['endtime'] > time()}
		<div class="chaihb" id="chaihb" style="display: none;">	
			<div class="weui_mask"></div>
			<div class="hongbao">
				<div class="topcontent">
					<div class="avatar">
						<img src="{php echo tomedia($_SESSION['account']['logo'])}" alt="" width="80" height="80">
					</div>
					<h2 style="color:#fff">{$_SESSION['account']['title']}</h2>
					<span class="text">给你发了一个红包</span>
					<div class="description" style="color:#fff">恭喜发财 大吉大利</div>
				</div>
				<div class="chai" id="chai">
					<span class="fontchai">拆红包</span>
				</div>
			</div>
		</div>
		<div class="page_rain">
			<div class="div bg_1"></div>
			<div class="lasttimes">您还剩<font class="timesnumber">{$leftPlayCount}</font>次点击</div>
			
			{if $this->module['config']['bgmusic']==1}
			<!-- music-->
			<div id="music">
				<div id="audio-btn" class="on" onclick="music.changeClass(this,'media')">
					<audio loop="loop" src="{$file}/public/images/music.mp3" id="media" preload="preload"></audio>
				</div>
			</div>	
			{/if}
		</div>
	
	{/if}
	

	<!-- 活动未开始或已结束提示 -->	
	{if $item['starttime'] > time() || time() > $item['endtime']}
		<div id="loadingToast" class="weui_loading_toast">
		<div class="weui_mask"></div>
			<div class="weui_toast arterweima">
				<div class="tip" style="max-height:280px;margin-top:25px;">
					<div class="tipimg" style="padding-top:30px"><img src="{$file}/public/images/nostart.png"/></div>
					{if $item['starttime'] > time()}
						<p style="text-align:center">活动还未开始呢</p>
						<p style="text-align:center">活动时间：<br>{$item['starttime2']}—{$item['endtime2']}</p>
					{elseif time() > $item['endtime']}
						<p style="text-align:center">活动已经结束啦！下次来早点。</p>					
					{/if}
				</div>
				<div class="tipfoot">
					<button class="tipbtn btnleft tipleft">活动规则</button>
					<button class="moneybtn tipbtn tellfriend">告诉小伙伴</button>
				</div>
			</div>
		</div>
	{/if}


	<!-- 已无点击次数提示 -->
	<div id="loadingToast" class="weui_loading_toast notimes" style="display:none;">
    <div class="weui_mask"></div>
		<div class="weui_toast arterweima">
			<font class="closerweima closefont"></font><br>
			<div class="tip" style="max-height:280px;">
				<div class="tipimg"><img src="{$file}/public/images/sorry.png"/></div>
				<p>对不起，您的点击次数已经用完了！</p>
				<p>增加点击次数方式：邀请朋友参与，每位参与的朋友可以为您积攒<font style="color:red;font-size:18px">{['config']['givetimes']}</font>次点击。</p>				
			</div>
			<div class="moneyfoot toewm">
				<a href="" class="moneybtn">点击生成邀请二维码</a>
			</div>
		</div>
	</div>
	
	<!-- 红包页面 -->
	<div id="loadingToast" class="weui_loading_toast moneyshow" style="display:none;">
    <div class="weui_mask"></div>
		<div class="weui_toast arterweima">
			<a href="{$welcomeurl}"><font class="fa fa-close closerweima closefont"></font></a><br>
			<div class="money">
				<div class="moneytop"></div>
				<div class="moneyimg">
					<img src="{php echo tomedia($_SESSION['account']['logo'])}"">
				</div>
				<div class="moneyfont">
					<p>{$_SESSION['account']['title']}的红包</p>
					<p style="color:#cfcac7">恭喜发财，大吉大利！</p>
				</div>
				<div class="moneynum">
				<p><font class="moneysize">1.01</font><font style="font-size:12px;">元</font></p>
				</div>
				<p style="font-size:12px;">已通过公众号发送，请查收</p>
			</div>
			<div class="moneyfoot">
				<button class="moneybtn tellfriend">分享活动给朋友</button>
			</div>
		</div>
	</div>
{elseif $flag == 1}

	<!-- 引导关注 -->
	<div id="loadingToast" class="weui_loading_toast">
	<div class="weui_mask"></div>
		<div class="weui_toast arterweima">
			<div class="tip" style="max-height:280px;margin-top:25px;">
				<img class="erweima" src="" />
				<p class="yindao">请长按上方二维码，订阅我们后再参与，以便为您发送奖品。</p>
			</div>
			<div class="tipfoot">
				<button class="tipbtn btnleft tipleft">活动规则</button>
				<button class="moneybtn tipbtn tellfriend">告诉小伙伴</button>
			</div>
		</div>
	</div>	
	
{elseif $flag == 2}	
	<div id="loadingToast" class="weui_loading_toast">
	<div class="weui_mask"></div>
		<div class="weui_toast arterweima">
			<div class="tip" style="max-height:280px;margin-top:25px;">
				<div class="tipimg" style="padding-top:30px"><img src="{$file}/public/images/nostart.png"/></div>
					<p style="text-align:center">奖品已经被小伙伴抢完了，下次来早点吧。</p>
			</div>
			<div class="tipfoot">
				<button class="tipbtn btnleft tipleft">活动规则</button>
				<button class="moneybtn tipbtn tellfriend">告诉小伙伴</button>
			</div>
		</div>
	</div>
{elseif $flag == 3}	
	<div id="loadingToast" class="weui_loading_toast">
	<div class="weui_mask"></div>
		<div class="weui_toast arterweima">
			<div class="tip" style="max-height:280px;margin-top:25px;">
				<div class="tipimg" style="padding-top:30px"><img src="{$file}/public/images/nostart.png"/></div>
					<p style="text-align:center">对不起，您所在的区域<br>不在活动举办区域内</p>
			</div>
			<div class="tipfoot">
				<button class="tipbtn btnleft tipleft">活动规则</button>
				<button class="moneybtn tipbtn tellfriend">告诉小伙伴</button>
			</div>
		</div>
	</div>
{/if}
	<!-- 分享图片 -->
	<div class="shareimg" style="display:none">
		<img src="{$file}/public/images/share.png"/>
	</div>
	<!-- 活动规则 -->
	<div class="rule parent" style="display:none;">
		<div class="rule-body">			
		<div class="ruleclose close"><span class="fa fa-close"></span></div>			
		</div>
	</div>	
<script>
var id = '{php echo $e}';
var token = '{php echo $token}';
var winningRate = '{php echo $item['winningRate']}';
        var welcomeurl = '{php echo $welcomeurl}';
        var ajaxurl = "../api.php?this=custom&token="+token+"&plugin=jy_h5game&action=chouhb&rid="+id;
		$('.tellfriend').click(function(){
			$('.shareimg').fadeIn();
			
		});		
		$('.tipleft').click(function(){
			$('.rule').fadeIn();			
		});		
		$('.shareimg').click(function(){
			$('.shareimg').fadeOut();			
		});	
		$('.close').click(function(){
		$('.parent').fadeOut();		
});	
{if 1==1}
	var prizepro = "{php echo $this->module['config']['prizepro']}"*1;
	var times = "{php echo $leftPlayCount}";
	if(times!='无限'){
		times=times*1;
	}
	var getprize = 0;
	var Timerr = setInterval(aa,800);
	var removepackage = setInterval(function(){
				for(var jj=0;jj<$('.div>div').size()/4;jj++){
					$('.div>div').eq($('.div>div').size()-jj).remove();
				}
	},1000);
	function aa(){
		for(var i=0;i<4;i++){	
			var m=parseInt(Math.random()*700+100);
			var j2=parseInt(Math.random()*300+1200);
			var j=parseInt(Math.random()*($(window).width()+400)+000);
			var j1=parseInt(Math.random()*300+300);
			var n=parseInt(Math.random()*10+(-10));
			$('.div').prepend('<div class="dd"></div>');
			$('.div').children('div').eq(0).css({'left':j,'top':n});
			$('.div').children('div').eq(0).animate({'left':j-j1,'top':$(window).height()+20},2800);
		}
	};
	$(document).on('touchstart', '.dd', function(){
		//alert(times);
		if(times > 0 || times=='无限'){
				$.ajax({
					url : ajaxurl,
					datatype : 'json',
					type : 'post',
					success : function(data){
						//var obj =  JSON.parse(data);
						var obj = eval('('+decodeURI(data)+')');
						  //console.log(data);
						 if(obj.message.code == 1){
							// alert(JSON.stringify($(this)));
							$('.dd').css("background-position","0 -100px");		
						 }else if(obj.message.code == 0){
						   getprize = 1;
				           $(".chaihb").fadeIn();
				           $(".div").remove();
				           clearInterval(Timerr,20);
				           $(".div").removeClass("bg_1");
						 }else if(obj.message.code == 10998){
						  alert(obj.message.errorMsg);
						 }
						$('.chai').click(function(){
							//alert('chai');
							$('.chai').unbind();
							$('.chai').addClass('rotate').delay(1000);
							if(getprize == 1){
								// alert(obj.message.code);
								if(obj.status == '0'){
									alert('一定是你的姿势不对!');
									location.href="";
								}else if(obj.status == '1'){
									alert('红包已经被抢完了');
									location.href="";						
								}else if(obj.status == '2'){
									alert('你领的够多了，留给别人吧。');
									location.href="";							
								}else if(obj.status == '3'){
									$('.chaihb').fadeOut(500);
									$('.moneysize').text(obj.message.fee);
									$('.moneyshow').fadeIn(500);
									
								}else if(obj.status == '4'){
									alert(obj.err_code_des);
									location.href="";							
								}else{
									//alert(obj.err_code_des);
									//alert('else');
									$('.chaihb').fadeOut(500);
									$('.moneysize').text(obj.message.fee);
									$('.moneyshow').fadeIn(500);
									
									$.ajax({
										url : "../api.php?this=custom&token="+token+"&plugin=jy_h5game&action=chouhb&rid="+id+"&fee="+obj.message.fee+"&op=sendhb",
										datatype : 'json',
										type : 'post',
										success : function(data){
											var re = JSON.parse(data);
											//alert(re.message.res.return_msg);
											if(re.message.res.result_code == 'FAIL'){
												alert('红包发送失败，请联系管理员！');
											}else if(re.message.res.result_code == 'SUCCESS'){
												alert('红包发送成功，请在公众号查收！');
											}else{
												alert('领取余额红包成功，请在会员中心查看');
											}
										}
									});
								}
						}else{
							alert('错误了！');
							location.href="http://www.baidu.com";
						}
					});
			}
		});
		if(times!='无限'){
			times--;
			$('.timesnumber').text(times);
		}
	}
});
{/if}
	{if $flag == 1}
		$('.guanzhu').show();
	{/if}
	
	{if !empty($this->module['config']['bgimg'])}
		$('.bg_1').css('background-image','url({php echo tomedia($this->module['config']['bgimg'])})');
	{/if}


	/*wx.ready(function (){
	var shareData = {
		title: "{php echo '一大波红包雨来袭，您的朋友' . $userinfo['nickname'] . '邀请您来围观'}",
		desc: "{php echo '一大波红包雨来袭，您的朋友' . $userinfo['nickname'] . '邀请您来围观'}",
		link: "",
		imgUrl: "{php echo $userinfo['headimgurl']}",
	};
//分享朋友

	wx.onMenuShareAppMessage({
	    title: shareData.title,
	  	desc: shareData.desc,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	    	window.location.href =adurl;
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});
//分享QQ
	wx.onMenuShareQQ({
	    title: shareData.title,
	  	desc: shareData.desc,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	    	window.location.href =adurl;
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});
//分享QQ空间
	wx.onMenuShareQZone({
	    title: shareData.title,
	  	desc: shareData.desc,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	    	window.location.href =adurl;
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});	
//朋友圈
	wx.onMenuShareTimeline({
	  	title: shareData.title,
	  	link: shareData.link,
	  	imgUrl:shareData.imgUrl,
	  	trigger: function (res) {
	  	},
	  	success: function (res) {
	    	window.location.href =adurl;
	  	},
	  	cancel: function (res) {
	  	},
	  	fail: function (res) {
	    	alert(JSON.stringify(res));
	  	}
	});
});		
*/
/*music*/
/*
var music = {
	changeClass: function (target,id) {
       	var className = $(target).attr('class');
       	var ids = document.getElementById(id);
       	(className == 'on')
           	? $(target).removeClass('on').addClass('off')
           	: $(target).removeClass('off').addClass('on');
       	(className == 'on')
           	? ids.pause()
           	: ids.play();
   	},
	play:function(){
		document.getElementById('media').play();
	}
}
music.play();
*/
</script>	
	
</body>
</html>